<?php
if(isset($_POST['SubmitCategory']))
{
	if($_FILES['import']['name'])
	{
	$sourcename = "import_users.xls";
	move_uploaded_file($_FILES['import']['tmp_name'], "uploads/excel/".$sourcename);
	}
	if($sourcename!="")
	{
		require_once 'excelRead/Excel/reader.php';
		$data = new Spreadsheet_Excel_Reader();
		
		$data->read('uploads/excel/import_users.xls');
		
		error_reporting(E_ALL ^ E_NOTICE);
		for ($j = 1; $j <= $data->sheets[0]['numRows']; $j++)
		{
			$str = "insert into resource_centre set concept='".$data->sheets[0]['cells'][$j+1][1]."',";
			$str.="url='".$data->sheets[0]['cells'][$j+1][2]."',book_title='".$data->sheets[0]['cells'][$j+1][3]."',";
			$str.="publisher='".$data->sheets[0]['cells'][$j+1][4]."',";
			$str.="city='".$data->sheets[0]['cells'][$j+1][5]."',year='".$data->sheets[0]['cells'][$j+1][6]."',";
			$str.="edition='".$data->sheets[0]['cells'][$j+1][7]."',issuenumber='".$data->sheets[0]['cells'][$j+1][8]."',";
			$str.="pagenumber='".$data->sheets[0]['cells'][$j+1][9]."',firstname='".$data->sheets[0]['cells'][$j+1][10]."',";
			$str.="lastname='".$data->sheets[0]['cells'][$j+1][11]."',";
			$str.="in_text1='".$data->sheets[0]['cells'][$j+1][12]."',in_text2='".$data->sheets[0]['cells'][$j+1][13]."',";
			$str.="status='1'";
			//echo $str;
			if($data->sheets[0]['cells'][$j+1][1]!="")
			{
				$exe = mysql_query($str);
			}
		}	
		echo "<script>location.href='index.php?tc=resource';</script>";
	}
}
?>
<table border="0" width="100%" align="center" >
<tr>
	<td width="46%" align="left"><span style="color:#1B78B7; font-size:14px; font-weight:bold">
    Resource Centre</span>&nbsp; 
	<!--<input type="button" name="addnew" value="Add New" onclick="return show();" />-->
	</td>
	<td width="40%" align="right" class="font12">
    <a href="index.php?tc=resource" class="font12">Manage Resource Centre</a></td>
</tr>
<tr>
	<td background="images/topline.gif" colspan="3" height="11"></td>
</tr>    
</table>
<form name="formBook" action="" method="post" enctype="multipart/form-data">
<table width="99%" align="center" border="0"  class="list" cellpadding="5">
  <tbody>
  <tr>
    <td width="21%" align="right" valign="middle" class="font12">Import XLS file</td>
    
    <td align="left" valign="middle" colspan="2">
      <input type="file" style="width: 220px;"  class="txtborder" id="import" name="import"> </td>
  </tr>  
  <tr>
    <td align="left" valign="middle">&nbsp;</td>
    <td align="left" valign="middle" colspan="2">
      <input type="submit" name="SubmitCategory" value="Import"></td>
  </tr>
</tbody></table>
</form>

